package com.dongge.service;

import com.dongge.dao.CURDDaoBase;
import com.dongge.entity.Comment;

import java.util.Collections;
import java.util.List;

/**
 * Created by Administrator on 2015/10/17.
 */
public class CommentService1 extends CURDDaoBase<Comment>{

    private ArticleService articleService;

    /**
     * 获取文章的评论列表(一级评论）
     * @param articleId
     * @return
     */
    public List<Comment> getArticleComments(Long articleId){
        if(articleId == null)
            return Collections.emptyList();
        String hsql =
                "from Comment p where p.article = :articleId and p.parent is null";
        return getSession().createQuery(hsql)
                .setLong("articleId",articleId)
                .list();
    }

    public ArticleService getArticleService() {
        return articleService;
    }

    public void setArticleService(ArticleService articleService) {
        this.articleService = articleService;
    }
}
